function TreeUtil({id, parentId, children, tree, item}) {
    this.id = id
    this.parentId = parentId
    this.children = children
    this.tree = tree
    this.item = item

    this.parentList = []
}
TreeUtil.prototype.getPlace = function () {
  
    var find = (tree, item) => {
        var p = this.findParent(tree, item)
        if (p) {
            this.parentList.push(p)
            find(tree, p)
        }
    }
    find(this.tree, this.item)
    return this.parentList.reverse()
    
}
TreeUtil.prototype.findParent = function (tree, item) {
    var parent = null
    var find = (tree, item) => {
        for (let child of tree) {
            if (child[this.id] == item[this.parentId]) {
                parent = child
            }
            if (child[this.children]) {
                find(child[this.children], item)
            }
        }
    }
    find(tree, item)

    return parent
}   

export default TreeUtil